package framework.utils;

import java.util.HashMap;

import android.content.res.Resources;

public class ResourceManager<ResourceType> {

	HashMap<Integer, ResourceType> mResources;
	Resources mRes;
	ResourceManager<ResourceType> mManager = null;
	public enum Type {DRAWABLE};

	@SuppressWarnings("unchecked")
	protected ResourceManager(int[] ids, Type type)
	{
		mRes = GlobalManager.GlobalContext.getResources();
		mResources = new HashMap<Integer, ResourceType>();
		switch(type)
		{
		case DRAWABLE:
			for(int i =0; i< ids.length; i++) {
				mResources.put(ids[i], (ResourceType) mRes.getDrawable(ids[i]));
			}
			break;
		default:
			break;
		}
	}

	public ResourceManager(){
	}

	public ResourceManager<ResourceType> getInstance(int[] ids, Type type)
	{
		if(mManager ==  null)
			mManager = new ResourceManager<ResourceType>(ids, type);
		return mManager;
	}

	public ResourceType getResource(int id){
		return mResources.get(id);
	}
}